//
//  CustomTableViewCell.m
//  10-homework
//
//  Created by dllo on 16/7/27.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CustomTableViewCell.h"
#import "SCJCycleImages.h"
#import "UIView+FrameChange.h"
#import "CycleImage.h"
#import "CustomView.h"
#import "CycleImage.h"
@interface CustomTableViewCell ()

@property (nonatomic, strong) SCJCycleImages *scjCycleImage;
@property (nonatomic, strong) CustomView *oneView;
@property (nonatomic, strong) CustomView *twoView;
@property (nonatomic, strong) CustomView *threeView;
@property (nonatomic, strong) CustomView *fourView;
@property (nonatomic, strong) CycleImage *cycleImage;

@end

@implementation CustomTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatCircleImage];
    }

    return self;
}
- (void)creatCircleImage {

    SCJCycleImages *cycleImages = [[SCJCycleImages alloc] initWithFrame:CGRectMake(0, 0, self.contentView.cj_width, self.contentView.cj_heigh - 110)];
    [self.contentView addSubview:cycleImages];
    self.cycleImage = [[CycleImage alloc] init];
    NSMutableArray *imageArray = [NSMutableArray array];
    for (NSDictionary *dic in _cycleImage.cycleImageArray) {
        NSString *urlStr = [dic objectForKey:@"picCover"];
        NSURL *nsurlofimage = [NSURL URLWithString:urlStr];
        NSData *dataofimage = [NSData dataWithContentsOfURL:nsurlofimage];
        UIImage *image = [UIImage imageWithData:dataofimage];
        
        [imageArray addObject:image];
        // 将数组处理成image类型再添加
     }
    [cycleImages addImagesArrayWith:imageArray];
    CustomView *oneView = [[CustomView alloc] initWithFrame:CGRectZero imageName:@"1" title:@"贷款买车"];
    [self.contentView addSubview:oneView];
    CustomView *twoView = [[CustomView alloc] initWithFrame:CGRectZero imageName:@"2" title:@"直销车型"];
    [self.contentView addSubview:twoView];
    CustomView *threeView = [[CustomView alloc] initWithFrame:CGRectZero imageName:@"3" title:@"低价买车"];
    [self.contentView addSubview:threeView];
    CustomView *fourView = [[CustomView alloc] initWithFrame:CGRectZero imageName:@"4" title:@"二手车"];
    [self.contentView addSubview:fourView];

}





- (void)layoutSubviews {

    _scjCycleImage.frame = CGRectMake(0, 0, self.contentView.cj_width, self.contentView.cj_heigh - 110);
    _oneView.frame = CGRectMake(0, self.contentView.cj_heigh - 110, self.contentView.cj_width / 4, 110);
    _twoView.frame = CGRectMake(_oneView.cj_width, self.contentView.cj_heigh - 110, self.contentView.cj_width / 4, 110);
    _threeView.frame = CGRectMake(_oneView.cj_width * 2, self.contentView.cj_heigh - 110, self.contentView.cj_width / 4, 110);
    _fourView.frame = CGRectMake(_oneView.cj_width * 3, self.contentView.cj_heigh - 110, self.contentView.cj_width / 4, 110);


}










- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
